import subprocess
import os
# 开了启代理器，导致无法访问localhost，关闭代理器即可。
# 或者 os.environ['NO_PROXY'] = 'modelscope.cn'   os.environ['NO_PROXY'] = 'localhost,0.0.0.0,127.0.0.1'
# os.environ['NO_PROXY'] = 'modelscope.cn'
os.environ['NO_PROXY'] = 'localhost,0.0.0.0,127.0.0.1'



def subprocess_instruct():
    print(os.path.abspath("pretrained_models/CosyVoice-300M-Instruct"))
    subprocess.run(
        ["python", "webui.py", "--port", "50003", "--model_dir", "pretrained_models/CosyVoice-300M-Instruct"])

def subprocess_300M():
    print(os.path.abspath("pretrained_models/CosyVoice-300M"))
    subprocess.run(
        ["python", "webui.py", "--port", "50003", "--model_dir", "pretrained_models"])

def subprocess_2():
    #     pip install deepspeed bitsandbytes
    print(os.path.abspath("pretrained_models/CosyVoice2-0.5B"))
    subprocess.run([
        "python", "webui.py",
        "--port", "50003",
        "--model_dir", "pretrained_models/CosyVoice2-0.5B"
    ])

def main():
    subprocess_2()

if __name__ == "__main__":
    main()